#include <stdio.h>
#include <string.h>

int dp[1001][1001];
char s1[1001], s2[1001];

int main()
{
    int i, j, len1, len2;
    while (1) 
    {
          if (scanf("%s%s", &s1, &s2) == EOF) break;
          len1 = strlen(s1);
          len2 = strlen(s2);
          memset(dp, 0, sizeof(dp));
          
          
          for (i = 0; i < len1; ++i)
              for (j = 0; j < len2; ++j)
              {   
                  if (s1[i] == s2[j]) dp[i][j] = 1;
                  else dp[i][j] = 0;
                  if (s1[i] == s2[j] && i>=1 && j>=1) 
                     dp[i][j] += dp[i-1][j-1];
                  if (i >= 1 && dp[i][j] < dp[i-1][j]) dp[i][j] = dp[i-1][j];
                  if (j >= 1 && dp[i][j] < dp[i][j-1]) dp[i][j] = dp[i][j-1];
              }
          printf("%d\n", dp[len1-1][len2-1]);
    }
    
    
}
